(in-package :timeclock)

(define-application-frame time-inspector ()
  ((employee :initarg :employee
	     :accessor employee))
;  (:menu-bar menubar-command-table)
  (:panes
   (employee-info-pane :application
		       :display-function #'display-employee-info-pane)
   (intervals-pane :application
		   :display-function #'display-intervals-pane))
  (:layouts
   (default
       (vertically ()
	 (6/7 employee-info-pane)
	 (1/7 intervals-pane)))))

(defmethod display-employee-info-pane ((frame time-inspector) stream)
  (with-slots (employee) frame
    (format stream "~A, $~$/hour (~:[out~;in~])"
	    (name employee)
	    (/ (hourly-wage employee) 100)
	    (in-p employee))))

(defmethod display-intervals-pane ((frame time-inspector) stream)
  (formatting-table (stream :x-spacing 50)
    (formatting-row (stream)
      (with-text-face (stream '(:bold :italic))
	(formatting-cell (stream) (write-string "In" stream))
	(formatting-cell (stream) (write-string "Out" stream))))
    (dolist (interval (time-intervals (employee frame)))
      (present interval 'time-interval :stream stream))))
#+nil
(run-frame-top-level
 (make-application-frame 'time-inspector
			 :height 330
			 :width 520
			 :employee (car *employees*)))